import { GTextFormat } from "../../../common/GTextFormat";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { EToplistType } from "../../../../Message/Public/EToplistType";
import { GuildRankItem } from "./GuildRankItem";
type int = number;
//class GuildRankSprite
    
    export  class GuildRankSprite /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._itemArr = [];
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this.headTf = new GTextFormat("", 12, 16777113);
            this.rankTxt = this.createTxt(0, 0, 30, 30, Language.getString(32063));
            this.nameTxt = this.createTxt(85, 0, 50, 30, Language.getString(32067));
            this.campTxt = this.createTxt(165, 0, 30, 30, Language.getString(32068));
            this.valueTxt = this.createTxt(240, 0, 65, 30, Language.getString(32079));
            this.attributeTxt = this.createTxt(320, 0, 45, 30, Language.getString(32069));
            this.rangeTxt = this.createTxt(405, 0, 60, 30, Language.getString(32070));
            var loc1=ObjCreate.createBg(0, 23, 460, 2, this, ImagesConst.SplitLine);
            this._sprite = new Object /* flash.display.Sprite */();
            this._sprite.x = 0;
            this._sprite.y = 0;
            addChild(this._sprite);
            this.createItem();
            return;
        }

        /* internal  */createTxt(arg1: int, arg2: int, arg3: int, arg4: int, arg5: string): Object /* flash.text.TextField */
        {
            var loc1=null;
            (loc1 = new Object /* flash.text.TextField */()).x = arg1;
            loc1.y = arg2;
            loc1.width = arg3;
            loc1.height = arg4;
            loc1.defaultTextFormat = this.headTf;
            loc1.text = arg5;
            loc1.selectable = false;
            addChild(loc1);
            return loc1;
        }

        public resetTextPos(arg1: int): void
        {
            var loc1=arg1;
            switch (loc1) 
            {
                case EToplistType._EToplistTypeGuildLevel:
                {
                    this.valueTxt.text = Language.getString(32079);
                    this.valueTxt.x = 240;
                    this.attributeTxt.text = Language.getString(32069);
                    this.attributeTxt.x = 320;
                    break;
                }
                case EToplistType._EToplistTypeGuildBloom:
                {
                    this.attributeTxt.text = Language.getString(32080);
                    break;
                }
                case EToplistType._EToplistTypeGuildAsset:
                {
                    this.valueTxt.text = Language.getString(32109);
                    this.valueTxt.x = 230;
                    this.attributeTxt.text = Language.getString(32110);
                    this.attributeTxt.x = 315;
                    break;
                }
                case EToplistType._EToplistTypeGuildWarCredit:
                {
                    this.attributeTxt.text = Language.getString(32073);
                    break;
                }
            }
            return;
        }

        /* internal  */createItem(): void
        {
            var loc3=null;
            var loc1=0;
            var loc2=30;
            var loc4=0;
            while (loc4 < 10) 
            {
                loc3 = new GuildRankItem();
                loc3.x = loc1;
                loc3.y = loc2;
                loc2 = loc2 + loc3.height;
                this._itemArr.push(loc3);
                loc3.addEventListener(flash.events.MouseEvent.CLICK, this.onMouseClickHandler);
                addChild(loc3);
                ++loc4;
            }
            return;
        }

        /* internal  */onMouseClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < 10) 
            {
                loc1 = this._itemArr[loc2] as GuildRankItem;
                if (loc1.isDraw) 
                {
                    loc1.clearBgColor();
                }
                ++loc2;
            }
            loc1 = null;
            if (typeof arg1.target === "guildrankitem") 
            {
                loc1 = arg1.target as GuildRankItem;
            }
            else if (typeof arg1.currentTarget === "guildrankitem") 
            {
                loc1 = arg1.currentTarget as GuildRankItem;
            }
            if (loc1 && !(loc1.sEntityId == null)) 
            {
                loc1.drawGrayColor();
            }
            return;
        }

        public setData(arg1: Array<any>, arg2: int): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < 10) 
            {
                loc1 = this._itemArr[loc2] as GuildRankItem;
                loc1.updateItem(arg1[loc2], arg2);
                if (loc1.isDraw) 
                {
                    loc1.clearBgColor();
                }
                ++loc2;
            }
            if (this._itemArr && this._itemArr.length > 0) 
            {
                loc1 = this._itemArr[0] as GuildRankItem;
                if (loc1.sEntityId != null) 
                {
                    loc1.drawGrayColor();
                }
            }
            return;
        }

        public showTargetPlayer(arg1: int): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < 10) 
            {
                loc1 = this._itemArr[loc2] as GuildRankItem;
                if (loc1.isDraw) 
                {
                    loc1.clearBgColor();
                }
                if (loc1.rank == arg1) 
                {
                    loc1.drawGrayColor();
                }
                ++loc2;
            }
            return;
        }

        protected /* var */headTf: Object /* flash.text.TextFormat */;

        protected /* var */rankTxt: Object /* flash.text.TextField */;

        protected /* var */nameTxt: Object /* flash.text.TextField */;

        protected /* var */campTxt: Object /* flash.text.TextField */;

        protected /* var */valueTxt: Object /* flash.text.TextField */;

        protected /* var */attributeTxt: Object /* flash.text.TextField */;

        protected /* var */rangeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_sprite: Object /* flash.display.Sprite */;

        /* internal */ /* var */_itemArr: Array<any>;
    }
